package nayasis.common.db.manager.sql.condition.node;

import nayasis.common.db.manager.sql.ParamValue;
import nayasis.common.db.manager.sql.type.Type;
import nayasis.common.util.Validator;

public class ConstantNode extends Node {

    private ParamValue value;
    
    public ConstantNode( String value ) {
        
        super( Type.constant );
        
        if( Validator.isNumber(value) ) {
            
            this.value = new ParamValue( Integer.parseInt(value) );
            
        } else if( Validator.isNumeric( value ) ) {
            
            this.value = new ParamValue( Double.parseDouble(value) );
            
        } else {
            
            this.value = new ParamValue( value );
            
        }
        
    }

    public ParamValue getValue() {
        return this.value;
    }

    public String toString() {
        return this.value.toString();
    }
    
}
